package com.bw.module_service.view

import androidx.recyclerview.widget.GridLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route

import com.alibaba.android.arouter.launcher.ARouter

import com.baway.service.adapter.ServiceAdapter
import com.baway.service.model.ServiceData
import com.blankj.utilcode.util.ToastUtils
import com.bw.lib_base.path.RouterPath
import com.bw.lib_common.view.BaseMvvmFragment
import com.bw.module_service.R
import com.bw.module_service.databinding.FragmentServiceBinding

@Route(path = RouterPath.PATH_FRAGMENT_SERVICE)
class ServiceFragment : BaseMvvmFragment<FragmentServiceBinding>() {

    private lateinit var serviceAdapter: ServiceAdapter

    override fun initViews() {
        super.initViews()
        serviceAdapter = ServiceAdapter()
        serviceAdapter.data.clear()
        serviceAdapter.data.addAll(ServiceData.serviceCategoryList)
        mDataBinding.rv.adapter = serviceAdapter
        mDataBinding.rv.layoutManager = GridLayoutManager(context, 3)


        serviceAdapter.setOnItemClickListener { adapter, view, position ->
            val entity = serviceAdapter.data[position]


            when (entity.title) {
                "车辆管理" -> {
                    ARouter.getInstance().build(RouterPath.PATH_CAR_ACTIVITY).navigation()
                }

                "收银台" -> {
                    ARouter.getInstance().build(RouterPath.PATH_CASHIER_ACTIVITY).navigation()
                }

                "设备管理" -> {
                    ARouter.getInstance().build(RouterPath.PATH_DEVICE_ACTIVITY).navigation()
                }

                "巡检管理"->{
                    ARouter.getInstance().build(RouterPath.PATH_INSPECTION_ACTIVITY).navigation()

                }

                "人员管理"->{
                    ARouter.getInstance().build(RouterPath.PATH_STAFF_ACTIVITY).navigation()

                }

                "考勤管理"->{
                    ARouter.getInstance().build(RouterPath.PATH_ATTENDANCE_ACTIVITY).navigation()

                }


                "房源信息"-> {
                    ARouter.getInstance().build(RouterPath.PATH_HOUSE_ACTIVITY).navigation()

                }
                "车位管理"-> {
                    ARouter.getInstance().build(RouterPath.PATH_PARKING_ACTIVITY).navigation()


                }
                "巡逻管理"->{
                    ARouter.getInstance().build(RouterPath.PATH_PATROL_ACTIVITY).navigation()

                }
                "访客管理" -> {
                    ARouter.getInstance().build(RouterPath.PATH_MAINTENANCE_ACTIVITY).navigation()
                }
                "月卡会员" -> {
                    ARouter.getInstance().build(RouterPath.PATH_MONTH_VIP_ACTIVITY).navigation()
                }
                "公告管理" -> {
                    ARouter.getInstance().build(RouterPath.PATH_CULTURE_ACTIVITY).navigation()
                }
                "维修管理" -> {
                    ARouter.getInstance().build(RouterPath.PATH_REPAIR_ACTIVITY).navigation()
                }
                "物业报修"->{
                    ARouter.getInstance().build(RouterPath.PATH_REPAIR_ACTIVITY).navigation()
                }
                "即时通讯"->{
                    ARouter.getInstance().build(RouterPath.PATH_COMMUNICATION_ACTIVITY).navigation()

                }
                else -> {
                    ToastUtils.showShort(entity.title)
                }

            }

        }

    }

    override fun observeDataChange() {
    }

    override fun getLayoutId(): Int = R.layout.fragment_service

}